package o;

import android.annotation.TargetApi;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory.Options;
import android.os.Build;
import android.os.Build.VERSION;
import android.util.Log;
import androidx.annotation.GuardedBy;
import androidx.annotation.VisibleForTesting;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import java.io.File;

public final class wx {
    private static volatile wx ˊ;
    private static volatile int ˋ = DnsConfig.MAX_CACHE_ENTRIES;
    private static final File ˎ = new File("/proc/self/fd");
    private static volatile int ˏ = 700;
    @GuardedBy("this")
    private int ʼ;
    @GuardedBy("this")
    private boolean ʽ = true;
    private final boolean ॱ = ॱ();

    public static wx ˊ() {
        if (ˊ == null) {
            synchronized (wx.class) {
                if (ˊ == null) {
                    ˊ = new wx();
                }
            }
        }
        return ˊ;
    }

    @VisibleForTesting
    wx() {
    }

    public boolean ˋ(int i, int i2, boolean z, boolean z2) {
        if (!z || !this.ॱ || VERSION.SDK_INT < 26 || z2 || i < ˋ || i2 < ˋ || !ˏ()) {
            return false;
        }
        return true;
    }

    @TargetApi(26)
    public boolean ˏ(int i, int i2, Options options, boolean z, boolean z2) {
        boolean ˋ = ˋ(i, i2, z, z2);
        if (ˋ) {
            options.inPreferredConfig = Config.HARDWARE;
            options.inMutable = false;
        }
        return ˋ;
    }

    private static boolean ॱ() {
        if (Build.MODEL == null || Build.MODEL.length() < 7) {
            return true;
        }
        String substring = Build.MODEL.substring(0, 7);
        int i = -1;
        switch (substring.hashCode()) {
            case -1398613787:
                if (substring.equals("SM-A520")) {
                    i = 6;
                    break;
                }
                break;
            case -1398431166:
                if (substring.equals("SM-G930")) {
                    i = 5;
                    break;
                }
                break;
            case -1398431161:
                if (substring.equals("SM-G935")) {
                    i = 4;
                    break;
                }
                break;
            case -1398431073:
                if (substring.equals("SM-G960")) {
                    i = 2;
                    break;
                }
                break;
            case -1398431068:
                if (substring.equals("SM-G965")) {
                    i = 3;
                    break;
                }
                break;
            case -1398343746:
                if (substring.equals("SM-J720")) {
                    boolean z = true;
                    break;
                }
                break;
            case -1398222624:
                if (substring.equals("SM-N935")) {
                    i = 0;
                    break;
                }
                break;
        }
        switch (i) {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
                if (VERSION.SDK_INT == 26) {
                    return false;
                }
                return true;
            default:
                return true;
        }
    }

    private synchronized boolean ˏ() {
        boolean z = false;
        synchronized (this) {
            int i = this.ʼ + 1;
            this.ʼ = i;
            if (i >= 50) {
                this.ʼ = 0;
                i = ˎ.list().length;
                if (i < ˏ) {
                    z = true;
                }
                this.ʽ = z;
                if (!this.ʽ && Log.isLoggable("Downsampler", 5)) {
                    Log.w("Downsampler", "Excluding HARDWARE bitmap config because we're over the file descriptor limit, file descriptors " + i + ", limit " + ˏ);
                }
            }
            z = this.ʽ;
        }
        return z;
    }
}
